<template>
	<view>
		
		<view class="mb10" :class="{bt : index > 0}" style="border-color: rgb(234 234 234) !important;" v-for="( item , index) in list" :key="index">
			<view class="pd15">
				<view class="fixAutoNoPd middle" @tap="operateMore(item , index)">
					<view class="bold fz16">
						{{item.name}}
						<view class="tagGroup ml5" :class="{'yellowBg' : item.status == 2 , 'redBg' : item.status == 3}">
							<view class="tag">{{item.type}}</view>
							<view class="tag line ">{{item.statusStr}}</view>
						</view>
					</view>
					<view class="w20">
						<view class="iconfont icon-gengduo1 fz20 grey" v-if="role == 2"></view>
					</view>
				</view>
				
				<view class="fz14 grey pt5 fixAutoNoPd middle" @tap="makePhone(item.staffMobile)">
					<view class="pr5 gray w75">
						运维人员：
					</view> 
					<view v-if="item.staffName">
						{{item.staffName}} 
						<text class="ml5 main">{{item.staffMobile}}</text>
					</view>
					<view v-else>
						暂无
					</view>
				</view>
				<view class="fz14 grey pt5 fixAutoNoPd middle" v-if="item.staffName">
					<view class="pr5 gray w75">
						运维公司：
					</view> 
					<view>
						{{item.servicerName?item.servicerName:"无"}}
					</view>
				</view>
				<view class="fz14 grey pt5 fixAutoNoPd middle" @tap="openLocation(item)">
					<view class="pr5 gray w75">
						经纬度：
					</view> 
					<view>
						<view class="flex">
							<view>{{item.longitude}},{{item.latitude}}</view>
							<view class="sIcon-arrowRight"></view>
						</view>
					</view>
				</view>
			</view>
			<view class="flex rt plr15 pb15 mt10">
				<view class="btn line" @tap="showQrcode(item.qrcode)">
					查看二维码
				</view>
				<navigator class="btn shadow" :url="`/pages/stationMenu/stationMenu?id=${item.id}&type=${item.type}`">
					日常运维
				</navigator>
			</view>
			
		</view>
		
	</view>
</template>

<script>
	export default {
		name: 'station',
		data() {
			return {
				
			};
		},
		props: {
			list : {
				default : function(){
					return [];
				}
			},
			role:{
				default : 2
			}
		},
	
		
		methods: {
			
			
			makePhone:function(e){
				uni.makePhoneCall({
					phoneNumber:e 
				});
			},
			
			operateMore:function(item , index){
				if(this.role != 2){
					return ;
				}
				uni.showActionSheet({
					itemList:["编辑","删除"],
					success: (e) => {
						if (e.tapIndex == 0) {
							uni.navigateTo({
								url:`/pages/addStation/addStation0?sid=${item.id}`,
								fail: (e) => {
									console.log("e: ",e);
								}
							});
							return ;
						}
						if(e.tapIndex == 1){
							this.del(item.id,index);
						}
					}
				})
			},
			
			del:function(id , index){
				uni.showModal({
					title:'提示',
					content:'确认删除该站点吗？',
					confirmColor:'#3385ff',
					success : (e)=>{
						if(e.confirm){
							var data = {id} ;
							this.kit.get("/api/station/delete",data,res => {
								this.$emit("delete" , {id, index});	
							});
						}
					}
				});
			},
			
			showQrcode:function(e){
				uni.previewImage({
					urls:[e],
					current: e
				});
			},
			
			openLocation:function(item){
				uni.openLocation({
					latitude:item.latitude,
					longitude:item.longitude,
					name : item.name,
					address : item.companyName
				});
			},
			
		}
	}
</script>

<style>

</style>
